/**
 * 
 */
package game.breeze.util;

import java.lang.reflect.Field;
import java.util.LinkedList;
import java.util.UUID;

/**
 * @author wang
 * 
 */
public class CommonUtils {

	/**
	 * 输出字符串
	 * 
	 * @param s
	 */
	public static void printSection(String s) {
		s = "={ " + s + " }";

		while (s.length() < 160)
			s = "-" + s;

		System.out.println(s);
	}

	/**
	 * 返回32位唯一标识的ID
	 * 
	 * @return 32位唯一标识的ID
	 */
	public static String getUUId() {

		String s = UUID.randomUUID().toString().replaceAll("-", "");

		return s;
	}

	public static String desClass(Object obj) {
		StringBuffer sb = new StringBuffer();
		LinkedList<Class<?>> inherit = new LinkedList<Class<?>>();
		Class<?> cls = obj.getClass();
		while (cls != null) {
			inherit.offer(cls);
			cls = cls.getSuperclass();
		}
		try {
			while (inherit.size() > 0) {
				Field[] fields = inherit.pollLast().getDeclaredFields();
				for (Field f : fields) {
					if (!f.isAccessible()) {
						f.setAccessible(true);
					}
					sb.append(f.getName());
					sb.append("=");
					sb.append(f.get(obj));
					sb.append(";");
					if (f.isAccessible()) {
						f.setAccessible(false);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return sb.toString();
	}
}
